-----------------------------------------------------------------------------
--
-- Module      :  Main
-- Copyright   :  (c) Lakshmi Narasimhan
-- License     :  GNU-GPL
--
-- Maintainer  :  <lakshminaras2002 at gmail dot com>
-- Stability   :  provisional
-- Portability :  portable
--
--
--
---------------------------------------------------------------------------------
module Main where

import Graphics.UI.Gtk
import Graphics.UI.Gtk.Glade
import GhCalcUtils
import ParseUtils
import RecentList
import MenuHandlers

main = do
    -- TODO fix this using Maybe Monad Transformer
    result <- createLockFile
    case result of
        True -> do
            initGUI
            gladeFilePath <- getGladeFilePath
            Just glade_xml <- xmlNew gladeFilePath
            setupButtonHandlers glade_xml
            setupMenuHandlers glade_xml
            setupRecentList glade_xml
            mainWindow <- xmlGetWidget glade_xml castToWindow "wGhcalc"
            onDestroy mainWindow mainQuit
            widgetShowAll mainWindow
            mainGUI
        False -> do
            putStrLn "hello world"




